﻿using System;
using System.Collections.Generic;
using System.Text;

namespace WeatherEvent
{
    public class LoveIndexDisplay : IObserver, IDisplayElement
    {
        private WeatherChangeEventArgs _args;
        private float _sum;

        public LoveIndexDisplay(WeatherData wd)
        {
            wd.WeatherChange += this.Update;
        }
        public void Display()
        {
            Console.WriteLine($"恋爱指数为:\n温度：{_args.Temperature}℃\n湿度：{_args.Humidity}%\n压强：{_args.Pressure} \n恋爱指数为：{_sum}");
        }

        public void Update(object sender, WeatherChangeEventArgs args)
        {
            //throw new NotImplementedException();
            _args = args;
            _sum = (args.Temperature * args.Humidity) / args.Pressure;
            Display();
            if (_sum > 10)
            {
                Console.WriteLine("今天适合谈恋爱");
            }
            else
            {
                Console.WriteLine("今天你还是单身狗");
            }
        }
    }
}
